const app = getApp()
Page({
	data: {
		numList:[],
		user:{},
		courseList:[],
		newsList:[],
		baseUrl: app.globalData.baseUrl,
		keywords:'',
		page:{
			page:1,
			size:5,
			keywords:null,
		}
	},
	onShow(options) {
		let user = JSON.parse(wx.getStorageSync('user'))
		this.setData({
			user:user
		})
		this.getCourseList()
	},
	onLoad() {
		
	},
	getCourseList(){
		app.indexApi.homeData().then(a => {
			if (a.code == 0) {
				this.setData({
					courseList:a.data.videos,
					newsList:a.data.notice,
					
				})
			} 
		})
	},
	getApprovalList(){
		app.indexApi.approvalList().then(a => {
			if (a.code == 0) {
				this.setData({
					courseList:a.data.videos,
					newsList:a.data.notice,
					
				})
			} 
		})
	},
	search(){
		wx.navigateTo({
			url: '/pages/project/list/list?keywords='+ this.data.keywords
		})
	},
	//审批列表跳转
	pageTo(e) {
		let url = e.currentTarget.dataset.url
		wx.navigateTo({
			url: url
		})
	},
	pageToView(e) {
		let id = e.currentTarget.dataset.id
		console.log(id)
		wx.navigateTo({
			url: "/pages/newsList/view?id=" + id
		})
	},
	pageToVideo(e) {
		wx.navigateTo({
			url: "/pages/newsList/videoList"
		})
	},
	pageToVideoView(e) {
		let id = e.currentTarget.dataset.id
		wx.navigateTo({
			url: "/pages/newsList/videoView?id=" + id
		})
	},
	//优秀课程详情
	pageTo2(e) {
		let type = e.currentTarget.dataset.type
		let id = e.currentTarget.dataset.id
		var url
		if(type==1){
			url='/pages/project/list/view?id=' + id
		}else if(type==2){
			url='/pages/project/list/view2?id=' + id + '&title=项目计划'
		}else{
			url='/pages/project/list/view2?id=' + id + '&title=工作日志'
		}
		wx.navigateTo({
			url: url
		})
	},
	//公告列表
	pageToList(e) {
		var url=e.currentTarget.dataset.url
		wx.navigateTo({
			url: url
		})
	},
	pageTo3(e) {
		var url=e.currentTarget.dataset.url
		wx.navigateTo({
			url: url
		})
	},
	pageTo4(e) {
		var url=e.currentTarget.dataset.url
		if(wx.getStorageSync('user').roleId!=11){
			url='/pages/project/list/list?state=-1&launch=2&type=1'
		}
		wx.navigateTo({
			url: url
		})
	},
})